package cn.jeefast.modules.platform.controller;


import cn.jeefast.common.entity.MbProj;
import cn.jeefast.common.utils.R;
import cn.jeefast.modules.platform.service.MbProj1Service;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;
import cn.jeefast.common.base.BaseController;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author theodo
 * @since 2020-01-06
 */
@RestController
@RequestMapping("/mbProj")
@CrossOrigin
public class MbProj1Controller extends BaseController {

    @Autowired
    private MbProj1Service projService;

    /**
     * 查询全部项目列表
     * @return
     */
    @RequestMapping("/list")
    public R list(){
        EntityWrapper ew = new EntityWrapper();
        List list = projService.selectList(ew);
        return R.ok().put("data",list);
    }

    /**
     * 添加或编辑项目
     * @param proj
     * @return
     */
    @RequestMapping("addOrSave")
    public R addOrSave(MbProj proj){
        return projService.addOrSave(proj);
    }

    /**
     * 获取项目详细信息
     * @param id
     * @return
     */
    @RequestMapping("/detail")
    public R detail(Long id){
        MbProj mbProj = projService.selectById(id);
        return R.ok().put("data",mbProj);
    }

    /**
     * 删除项目
     * @param id
     * @return
     */
    @RequestMapping("/delete")
    public R delete(Long id){
        projService.deleteById(id);
        return R.ok();
    }
}
